#ifndef OBJECT_H
#define OBJECT_H

#include "color.h"
#include "eulerOperators.h"
#include <vector>

class Object{
    public:
        Object(int = 0);
        Object(int, Object *);
        ~Object();

        int getId() const {return id;};
        void setId(int _id) {id = _id;};

        bool isSelected() const {return selected;};
        void select(bool _b) {selected = _b;};

        void addVertex(Vertex *_v) {vertices.push_back(_v);};
        void addEdge(Edge *_e) {edges.push_back(_e);};
        void addFace(Face *_f) {faces.push_back(_f);};

        void delVertex(Vertex *_v);
        void delEdge(Edge *_e);
        void delFace(Face *_f);

        Vertex *getVertex(unsigned int _i) {return vertices[_i];};
        Edge *getEdge(unsigned int _i) {return edges[_i];};
        Face *getFace(unsigned int _i) {return faces[_i];};

        unsigned int getVerticesSize() {return vertices.size();};
        unsigned int getEdgesSize() {return edges.size();};
        unsigned int getFacesSize() {return faces.size();};

        void translate(const Vector3D &);
        void rotate(double, const Vector3D &, const Vector3D & = Vector3D(0,0,0), bool = false);
        void scale(const Vector3D &, const Vector3D & = Vector3D(0,0,0), bool = false);
        void sweep(Face *, const Vector3D &);

        double area() const;
        void draw(bool, bool, bool, bool) const;
        void updateMinMax();
        void getMinMax(Vector3D *_min, Vector3D *_max){*_min = min; *_max = max;};
        const EulerOperators &getEulerOperators(){return euler;};
        void setColor(const Color &);

        void makeArc(int, double, double, double, const Color &);
        void makePolygon(int, double, const Color &);
        void makeCuboid(double, const Color &);
        void makeSphere(double, const Color &);
        void makeCylinder(double, double, const Color &);
        void makeCone(double, double, const Color &);
        void makeHole(Face *, Face *);
        Vector3D calculateCenter() const;


    protected:
        void drawBox() const;


        int id;
        bool selected;
        Vector3D min, max;
        std::vector<Face *> faces;
        std::vector<Edge *> edges;
        std::vector<Vertex *> vertices;
        EulerOperators euler;
};

double toRad(double);
Matrix addTranslation(const Vector3D &);
Matrix addRotation(double, const Vector3D &, const Vector3D &, const Vector3D & = Vector3D(0,0,0));
Matrix addScale(const Vector3D &, const Vector3D &, const Vector3D & = Vector3D(0,0,0));

#endif
